package com.cdtye.itps.cms.service.defect;

import com.cdtye.common.mybatiscore.base.BaseService;
import com.cdtye.itps.cms.config.DataProperties;
import com.cdtye.itps.cms.dao.defect.entity.JcwDefectInfoPhoto;
import com.cdtye.itps.cms.dao.defect.vo.JcwDefectInfoPhotoVo;
import com.cdtye.itps.cms.mapper.defect.JcwDefectInfoPhotoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Service
public class JcwDefectInfoPhotoService extends BaseService<JcwDefectInfoPhotoMapper, JcwDefectInfoPhoto> {

    @Autowired
    private DataProperties dataProperties;

    public List<JcwDefectInfoPhoto> getByDefectInfoIdList(List<String> defectInfoList){
        if(CollectionUtils.isEmpty(defectInfoList)){
            return new ArrayList<>();
        }
        JcwDefectInfoPhotoVo vo = new JcwDefectInfoPhotoVo();
        vo.setBureauUrl(dataProperties.getBureauUrl());
        vo.setUnitUrl(dataProperties.getUnitUrl());
        vo.setDefectInfoIdList(defectInfoList);
        List<JcwDefectInfoPhoto> result = baseMapper.getByDefectInfoIdList(vo);
        return result;

    }

    public boolean insertDefectInfoPhoto(List<JcwDefectInfoPhoto> jdipList){
        return this.saveOrUpdateBatch(jdipList);
    }

    public List<JcwDefectInfoPhoto> findByDefectInfoId(String defectInfoId){
        return baseMapper.findByDefectInfoId(defectInfoId);
    }
}
